home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19980901-19981211 / 000241_news@newsmaster….columbia.edu _Thu Oct 29 19:24:48 1998.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@newsmaster.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id TAA02104
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Thu, 29 Oct 1998 19:24:48 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id TAA06910
  7.     for kermit.misc@watsun; Thu, 29 Oct 1998 19:24:47 -0500 (EST)
  8. Path: news.columbia.edu!panix!howland.erols.net!Supernews73!supernews.com!Supernews69!not-for-mail
  9. From: "Michael Rose" <mike@tegris.com>
  10. Newsgroups: comp.protocols.kermit.misc
  11. Subject: Re: sending variables on the command line
  12. Date: Thu, 29 Oct 1998 16:21:17 -0800
  13. Organization: http://www.supernews.com, The World's Usenet: Discussions Start Here
  14. Lines: 102
  15. Message-ID: <71b0p0$idm$1@supernews.com>
  16. References: <71810c$31v$1@supernews.com> <718456$a8l$1@apakabar.cc.columbia.edu>
  17. NNTP-Posting-Host: 207.153.137.197
  18. X-Trace: 909706848 C4TGOY8WA89C5CF99C usenet53.supernews.com
  19. X-Complaints-To: newsabuse@supernews.com
  20. X-Newsreader: Microsoft Outlook Express 4.72.3110.5
  21. X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
  22. Xref: news.columbia.edu comp.protocols.kermit.misc:9441
  23.  
  24. Thanks! Your information helped solve a number of problems I've had with
  25. scripting.
  26.  
  27. Regards,
  28.  
  29. Michael Rose
  30.  
  31. Frank da Cruz wrote in message <718456$a8l$1@apakabar.cc.columbia.edu>...
  32. >In article <71810c$31v$1@supernews.com>, Michael Rose <mike@tegris.com>
  33. wrote:
  34. >: I have a script that I would like to send variables from the command
  35. prompt.
  36. >:
  37. >: kermit  script-name  variable1  variable2  variable3 variable4
  38. >:
  39. >Let's assume you are talking about C-Kermit 6.0.
  40. >
  41. >: $kermit maillogs 10.2.2.14 joebloe joepasswd maillog
  42. >:
  43. >This can't work because "10.2.2.14", "joebloe", "joepasswd", and "maillog"
  44. >are not valid C-Kermit command-line arguments.
  45. >
  46. >: Any help would be greatly appreciated.
  47. >:
  48. >The trick that you are looking for is documented, somewhat obscurely,
  49. >on pages 353, 383, 469, and 513 of "Using C-Kermit", 2nd edition:
  50. >
  51. > 1. If you put an "=" sign (surrounded by whitespace) on the command line,
  52. >    the following words are ignored, but still assigned to the argument
  53. >    vector array, \&@[].
  54. >
  55. > 2. You can use a FOR loop to loop through the argument vector array
  56. >    elements until you find the one whose value is "=".
  57. >
  58. > 3. The ones after that are your variables.
  59. >
  60. >Example:
  61. >
  62. >  $kermit maillogs = 10.2.2.14 joebloe joepasswd maillog
  63. >
  64. >(note insertion of "=" sign)
  65. >
  66. >The maillogs script can retrieve the arguments as follows:
  67. >
  68. >  local \%i \%k
  69. >  for \%i 0 \v(args)-1 1 {
  70. >      xif equal "\&@[\%k]" "=" {
  71. >          assign \%k \%i
  72. >          increment \%k
  73. >          break
  74. >      }
  75. >  }
  76. >
  77. >At this point, if \%k is defined, it is the index of your first variable:
  78. >
  79. >  \&@[\%k]   is 10.2.2.14
  80. >  \&@[\%k+1] is joebloe
  81. >  \&@[\%k+2] is joepasswd
  82. >  \&@[\%k+3] is joepasswd
  83. >  \&@[\%k+4] is maillog
  84. >
  85. >Granted, this is obscure, nonintuitive, and cryptic.  The next version
  86. >of C-Kermit will include a much better way to access these variables:
  87. >within the script, you will be able to refer to these variables like this:
  88. >
  89. >  \%0 = the name of the script file   (maillogs)
  90. >  \%1 = the first argument after "="  (10.2.2.14)
  91. >  \%2 = the second argument after "=" (joeblow)
  92. >
  93. >and so on.  (This feature is not in C-Kermit 6.1 Beta.05; it will be in
  94. >7.0 Alpha.01 and in the next release of K-95 -- watch this space for
  95. >announcements.)
  96. >
  97. >By the way, the reason for the "=" is to allow a mixture of arguments to
  98. >Kermit and arguments to the script on the same command line.  Thus, both
  99. >examples above would work just as well if your command line was:
  100. >
  101. >  $kermit maillogs -i -Q -Y -H = 10.2.2.14 joebloe joepasswd maillog
  102. >
  103. >And finally, note that you can remove the word "kermit" from the command
  104. line
  105. >if you first:
  106. >
  107. >  chmod +x maillogs
  108. >
  109. >and put:
  110. >
  111. >  #!/usr/local/bin/kermit
  112. >
  113. >as the first line (substitute the actual pathname of the Kermit
  114. executable).
  115. >
  116. >Now you can just run the script as if it were a shell script (except that
  117. >you still need the "=" to precede the argument list):
  118. >
  119. >  $maillogs = 10.2.2.14 joebloe joepasswd maillog
  120. >
  121. >See p.513 for details.
  122. >
  123. >- Frank
  124.  
  125.